<template>
  <div id="new-guests">
    <div class="guest-list">
      <h2 class="text-align-center p-t-10 p-b-10"><i class="el-icon-back"></i> 最新留言 <i class="el-icon-right"></i></h2>
      <!-- 留言列表 -->
      <div v-if="guestList.length !== 0">
        <div class="guest" v-for="(item, index) in guestList" :key="index">
          <header class="h-30 l-h-30 flex">
            <div class="w-25 m-r-10"><img width="100%" class="border-r" :src="item.guestIcon" alt=""></div>
            <h4 class="color2">{{item.guestName}}</h4>
          </header>
          <div class="content">
            <div>{{item.guestContent}}</div>
            <div v-if="item.isReply" class="reply m-t-10 ">管理员回复: {{item.reply}}</div>
          </div>
          <footer>
            <div class="fz-14"><i class="el-icon-time"></i> {{item.createTime | dateTime}}</div>
          </footer>
        </div>
      </div>
      <div v-else class="p-t-30 text-align-center">
        <i class="el-icon-chat-square fz-50"></i>
        <h3>暂无留言</h3>
        <el-divider></el-divider>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      guestList: [],
      page: {
        pageSize: 5,
        currentPage: 1,
      },
    }
  },
  created() {
    this.getGuestList()
  },
  methods: {
    async getGuestList() {
      let res = await this.api.post('/client/getGuestList', this.page)
      if(res.code == 0) {
        this.guestList = res.data.guestList
      }
    },
  },
}
</script>

<style lang="scss">
  #new-guests {
    .guest-list {
      color: #606266;
      margin-top: 30px;
      border-top: 1px solid #DCDFE6;
      .guest {
        border-bottom: 1px dashed #DCDFE6;
        padding: 18px 0;
        img {
          vertical-align: middle;
        }
        .content {
          padding: 10px;
          border-left: 3px solid #ddd;
          background: #f6f6f6;
          margin: 14px auto;
          .reply {
            color: #fa6706;
          }
        }
      }
    }
  }
</style>